package day0811;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        int a = input / 1000;
        int b = input / 100 -a*10;
        int c = (input % 100 ) / 10;
        int d = input % 10;
        a =(a + 5)%10;
        b =(b + 5)%10;
        c =(c + 5)%10;
        d =(d + 5)%10;
        int t = a;
        a = d ;
        d = t;
        int k = b;
        b = c ;
        c = k;
        System.out.print(a);
        System.out.print(b);
        System.out.print(c);
        System.out.print(d);

    }

}
